1. Field of the Invention
The present invention relates to an image processing device and method, and a program, and particularly, relates to an image processing device and method, and a program which are suitable in the case of correcting the contrast of an image.
2. Description of the Related Art
Image processing for reducing gray levels of an image to compress the dynamic range thereof are called gray level compression or gray level transformation or the like, and in recent years, a variety of gray level compression or gray level transformation technology has been proposed (e.g., see Japanese Unexamined Patent Application Publication No. 2007-049540).
Now, description will be made with reference to FIGS. 1 through 3 regarding the gray level transformation processing performed with the invention described in Japanese Unexamined Patent Application Publication No. 2007-049540.
FIG. 1 is a block diagram illustrating a functional configuration example of a gray level transformation unit 11 for performing gray level transformation processing with the invention described in Japanese Unexamined Patent Application Publication No. 2007-049540. The gray level transformation unit 11 is configured of a brightness calculating unit 21, nonlinear transforming units 22L through 22B, a tone-curve calculating unit 23, tone-curve memory 24, γ_comp parameter memory 25, a reduction image generating unit 26, reduction image memory 27, an interpolation unit 28, mapping units 29-1 and 29-2, a contrast correction unit 30, gray level correction units 31R through 31B, and nonlinear inverse transforming units 32R through 32B.
With the gray level transformation unit 11, gray level compression processing for compressing the gray level of an image using a tone curve, and contrast correction processing for correcting contrast lost at the gray level compression processing are performed, wherein the gray level compression processing is performed by the tone-curve calculating unit 23, tone-curve memory 24, and mapping units 29-1 and 29-2, and the contrast correction processing is performed by the γ_comp parameter memory 25, reduction image generating unit 26, reduction image memory 27, interpolation unit 28, and contrast correction unit 30.
With the contrast correction processing, a low-frequency filter, which is realized by a combination of image reduction processing by the reduction image generating unit 26 and image correction processing by the interpolation unit 28, is employed to separate the components of a gray level-compressed image into overall brightness components made up of low-frequency components and contrast components, and subject the contrast components including not only high-frequency components but also low-or-medium-frequency components of the image to contrast correction. Thus, contrast correction, which is very natural even in appearance, can be performed without emphasizing the details of the image needlessly.
FIG. 2 is a block diagram illustrating a functional configuration example of the contrast correction unit 30. The contrast correction unit 30 is configured of a gain-value calculating unit 51 and a contrast emphasizing unit 52.
With brightness value Lc(n1)(p) of the gray level-compressed image input to the contrast correction unit 30, the contrast components are compressed with a tone curve. The compression level thereof depends on the inclination of the tone curve, so the more moderate the inclination slope is, the greater the compression level is. Accordingly, in order to restore the contrast of the image, it is desirable to emphasize the contrast components depending on the inverse number of the inclination of the tone curve. Note however, in such a case, there is a case wherein with around the saturation level and noise level of the brightness value, saturation in brightness is caused due to excessively strong contrast correction, and blackout or whiteout occurs on the corrected image.
Therefore, with the contrast correction unit 30, the gain-value calculating unit 51 obtains a gain value g(p) based on the brightness value Lc(n1)(p) after gray level compression using the gain properties shown in FIG. 3, and the contrast emphasizing unit 53 performs contrast correction using the gain value g(p) obtained by the gain-value calculating unit 51. Note that the horizontal axis direction of a graph shown in FIG. 3 represents the brightness value Lc(n1)(p) after gray level compression, and the vertical axis direction represents the gain value g(p).
With the gain properties shown in FIG. 3, when the brightness value Lc(n1)(p) is a predetermined intermediate brightness level Lmid(n1) which is generally equivalent to the middle of a range where the brightness value Lc(n1)(p) can take, the gain value g(p) is the maximum value, and as the brightness value Lc(n1)(p) approaches the minimum value Lmin(n1) or the maximum value Lmax(n1) of the range where the brightness value Lc(n1)(p) can take, the gain value g(p) is attenuated linearly, and with ranges where the brightness value Lc(n1)(p) is below the minimum brightness level Lmin(n1) and above the maximum value Lmax(n1), the gain value g(p) is zero. The gain value g(p) at the intermediate value Lmid(n1) is determined with γ_comp parameter which is determined with a predetermined constant contrastGain and the shape of the tone curve, which is contrastGain/γ_comp−1. The gain properties can be represented with the following Expression (1) and Expression (2).
                              k          ⁡                      (            p            )                          =                  {                                                    1                                                                                                        L                      c                                              (                                                  n                          ⁢                                                                                                          ⁢                          1                                                )                                                              ⁡                                          (                      p                      )                                                        >                                      L                    max                                          (                                              n                        ⁢                                                                                                  ⁢                        1                                            )                                                                                                                                                                                                              L                        c                                                  (                                                      n                            ⁢                                                                                                                  ⁢                            1                                                    )                                                                    ⁡                                              (                        p                        )                                                              -                                          L                      mid                                              (                                                  n                          ⁢                                                                                                          ⁢                          1                                                )                                                                                                                        L                      max                                              (                                                  n                          ⁢                                                                                                          ⁢                          1                                                )                                                              -                                          L                      min                                              (                                                  n                          ⁢                                                                                                          ⁢                          1                                                )                                                                                                                                                              L                    mid                                          (                                              n                        ⁢                                                                                                  ⁢                        1                                            )                                                        ≤                                                            L                      c                                              (                                                  n                          ⁢                                                                                                          ⁢                          1                                                )                                                              ⁡                                          (                      p                      )                                                        ≤                                      L                    max                                          (                                              n                        ⁢                                                                                                  ⁢                        1                                            )                                                                                                                                                                                                              L                        c                                                  (                                                      n                            ⁢                                                                                                                  ⁢                            1                                                    )                                                                    ⁡                                              (                        p                        )                                                              -                                          L                      mid                                              (                                                  n                          ⁢                                                                                                          ⁢                          1                                                )                                                                                                                        L                      min                                              (                                                  n                          ⁢                                                                                                          ⁢                          1                                                )                                                              -                                          L                      mid                                              (                                                  n                          ⁢                                                                                                          ⁢                          1                                                )                                                                                                                                                              L                    min                                          (                                              n                        ⁢                                                                                                  ⁢                        1                                            )                                                        ≤                                                            L                      c                                              (                                                  n                          ⁢                                                                                                          ⁢                          1                                                )                                                              ⁡                                          (                      p                      )                                                        <                                      L                    mid                                          (                                              n                        ⁢                                                                                                  ⁢                        1                                            )                                                                                                                          1                                                                                                        L                      c                                              (                                                  n                          ⁢                                                                                                          ⁢                          1                                                )                                                              ⁡                                          (                      p                      )                                                        <                                      L                    min                                          (                                              n                        ⁢                                                                                                  ⁢                        1                                            )                                                                                                                              (        1        )                                          g          ⁡                      (            p            )                          =                              (                                          contrastGain                                  γ                  comp                                            -              1                        )                    ·                      (                          1              -                              k                ⁡                                  (                  p                  )                                                      )                                              (        2        )            
The contrast emphasizing unit 52 employs the gain value g(p) calculated by the gain-value calculating unit 51 to calculate a brightness value Lu(n1)(p) subjected to contrast correction using the following Expression (3).
                                                                                          L                  u                                      (                                          n                      ⁢                                                                                          ⁢                      1                                        )                                                  ⁡                                  (                  p                  )                                            =                            ⁢                                                                    (                                                                  g                        ⁡                                                  (                          p                          )                                                                    +                      1                                        )                                    ·                                      (                                                                                            L                          c                                                      (                                                          n                              ⁢                                                                                                                          ⁢                              1                                                        )                                                                          ⁡                                                  (                          p                          )                                                                    -                                                                        L                                                      c                            ⁢                                                                                                                  ⁢                            1                                                                                (                                                          n                              ⁢                                                                                                                          ⁢                              1                                                        )                                                                          ⁡                                                  (                          p                          )                                                                                      )                                                  +                                                      L                                          c                      ⁢                                                                                          ⁢                      1                                                              (                                              n                        ⁢                                                                                                  ⁢                        1                                            )                                                        ⁡                                      (                    p                    )                                                                                                                          =                            ⁢                                                                    g                    ⁡                                          (                      p                      )                                                        ·                                      (                                                                                            L                          c                                                      (                                                          n                              ⁢                                                                                                                          ⁢                              1                                                        )                                                                          ⁡                                                  (                          p                          )                                                                    -                                                                        L                                                      c                            ⁢                                                                                                                  ⁢                            1                                                                                (                                                          n                              ⁢                                                                                                                          ⁢                              1                                                        )                                                                          ⁡                                                  (                          p                          )                                                                                      )                                                  +                                                      L                    c                                          (                                              n                        ⁢                                                                                                  ⁢                        1                                            )                                                        ⁡                                      (                    p                    )                                                                                                          (        3        )            
Note that Lc1(n1)(p) represents the overall brightness value of the pixel at a pixel position p.
Accordingly, the contrast of the brightness component around the intermediate brightness level Lmid(n1) is emphasized as compared with the contrast of the brightness component around the minimum value Lmin(n1) or maximum value Lmax(n1). More strictly, the contrast of the brightness component around the intermediate brightness level Lmid(n1) is emphasized as the brightness level approaches the intermediate brightness level Lmid(n1), and most contrast of the brightness component around the minimum value Lmin(n1) or maximum value Lmax(n1) is not emphasized. Thus, with the contrast-corrected image, whiteout or blackout due to saturation of brightness is prevented from occurring.
Also, an image contrast correction technique is also employed for other than an application wherein the contrast of a gray level-compressed image having a wide dynamic range is corrected. For example, in the photo-retouching field, in the case of an image shot by a camera being out of focus, correction has been generally performed wherein contrast correction is performed so as to particularly emphasize high-frequency contrast components, thereby approximating the image thereof to a focused image, and most photo-retouching software which provides a photo-retouching function implements the correction function thereof.
Incidentally, this kind of processing for emphasizing the high-frequency contrast of an image is frequently realized with image processing called unsharp masking. The unsharp masking is processing wherein, with each pixel of an image, the difference is calculated between the relevant pixel value and the weighted average value of neighborhood pixel values, and the difference value thereof is multiplied by an appropriate gain value, and the result thereof is added to the relevant pixel value. Here, the weighted average value of neighborhood pixel values is equivalent to a low-frequency component of the relevant pixel, and this is subtracted from the relevant pixel value, whereby the high-frequency contrast component of the relevant pixel is extracted. Also, the gain value is a parameter for emphasizing the extracted contrast component.
Also, of the unsharp masking processing implemented in existing photo-retouching software, some software includes a function for suitably adjusting the gain value so as to obtain more desirable effects.
For example, heretofore, there has been marketed photo-retouching software capable of setting the lower limit value of a contrast component to which contrast emphasis is applied as a threshold value. With this software, when the high-frequency contrast component of the relevant pixel is greater than a threshold value, the contrast component is emphasized with the specified gain value, and when the contrast component is below the threshold value, the gain value is set to zero, and consequently, the contrast component is not emphasized. Thus, a case can be prevented wherein a high-frequency noise component is also emphasized together with the contrast component.
Also, heretofore, there has been marketed photo-retouching software capable of setting the properties of the gain value further in detail. FIG. 4 is a graph illustrating the properties of the gain value of the unsharp masking processing of the photo-retouching software thereof. The horizontal axis of FIG. 4 indicates a local contrast value of an image, and the vertical axis indicates an emphasis rate of a contrast component, i.e., the gain value. With this software, as shown in FIG. 4, in addition to a lower limit value, respective parameters can be set, such as an upper limit value, a lower-limit gradual adjustment area, an upper-limit gradual adjustment area, an entire area effect, and an effect. Thus, in addition to the lower limit value of a contrast component to which contrast correction is applied, the upper limit can be set, whereby occurrence of brightness saturation with a strong contrast area subjected to excessive contrast emphasis, and occurrence of an image having excessively strong contrast to an unnatural extent, can be prevented.